//
//  YWEquInitParameterTableViewController.m
//  maintain
//
//  Created by Kyo on 16/11/3.
//  Copyright © 2016年 ewin. All rights reserved.
//

#import "YWEquInitParameterTableViewController.h"
#import "UIColor+CustomColors.h"
#import "UIScrollView+EmptyDataSet.h"

#import "UITableView+FDTemplateLayoutCell.h"
#import "YWUseMethodAndRangeCell.h"

#import "YWEquipmentManager.h"
#import "YWEquipment.h"

@interface YWEquInitParameterTableViewController ()<DZNEmptyDataSetDelegate, DZNEmptyDataSetSource>
@property (nonatomic, strong) NSMutableArray *dataSource;
@end

@implementation YWEquInitParameterTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"初始参数";
    
    [self setupData];
    
    [self.tableView registerClass:[YWUseMethodAndRangeCell class] forCellReuseIdentifier:YWUseMethodAndRangeCellIdentifier];
    self.tableView.backgroundColor = [UIColor customBackgroudColor];
    self.tableView.separatorColor = [UIColor customLineColor];
    self.tableView.tableFooterView = [[UIView alloc] init];
    self.tableView.emptyDataSetDelegate = self;
    self.tableView.emptyDataSetSource = self;
    self.tableView.estimatedRowHeight = 44.0f;
    self.tableView.rowHeight = UITableViewAutomaticDimension;
}

- (void)setupData{
    _dataSource = [NSMutableArray array];
    NSArray *initParameter = [[YWEquipmentManager shareManager] equipmentParametersWithEquipmentId:_equipmentId];
    [_dataSource addObjectsFromArray:initParameter];
}

#pragma mark - Table view data source
//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
//    return  [tableView fd_heightForCellWithIdentifier:YWUseMethodAndRangeCellIdentifier cacheByIndexPath:indexPath configuration:^(YWUseMethodAndRangeCell *cell) {
//        YWEquipmentInitialParameter *initParameter = _dataSource[indexPath.row];
//        cell.title = initParameter.propertyName.length?initParameter.propertyName:@"未填写";
//        cell.content = initParameter.propertyValue.length?initParameter.propertyValue:@"未填写";
//    }];
//}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataSource.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    YWUseMethodAndRangeCell *cell = [tableView dequeueReusableCellWithIdentifier:YWUseMethodAndRangeCellIdentifier];
    YWEquipmentInitialParameter *initParameter = _dataSource[indexPath.row];
    cell.title = initParameter.propertyName.length?initParameter.propertyName:@"未填写";
    cell.content = initParameter.propertyValue.length?initParameter.propertyValue:@"未填写";
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
